AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include('shared.lua')

function ENT:Initialize()
	self.BaseClass.Initialize(self)
	timer.Create(tostring(self.Entity), 180, 1, self.Remove, self)
end

function ENT:Use(activator, caller)
	self:GiveDrugEffects(caller)
	
	if caller:GetNWBool("Antidoted") then
		timer.Create(caller:SteamID() .. self.NWName, self.DrugTime, 1, self.TakeDrugEffects, self, caller)
	else
		timer.Create(caller:SteamID() .. self.NWName, self.DrugTime, 1, self.TakeDrugEffects, self, caller)
	end

	caller:SetHealth(caller:Health() + math.random(5, 15))
	if (caller:Health() > caller:GetMaxHealth() * 1.1) then
		caller:SetHealth(caller:GetMaxHealth() * 1.1)
	end
	
	self:SetNoDraw(true)
	self:SetMoveType(MOVETYPE_NONE)
	self:SetNotSolid(true)
	self:SetSolid(SOLID_NONE)
	self:SetRenderMode(RENDERMODE_NONE)
end

function ENT:GiveDrugEffects(ply)
	ply:ConCommand("pp_motionblur 1;pp_motionblur_addalpha 0.05;pp_motionblur_delay 0.035;pp_motionblur_drawalpha 0.75;pp_motionblur_drawalpha 0.75;pp_dof 1;pp_dof_initlength 9;pp_dof_spacing 100")
end

function ENT:TakeDrugEffects(ply)
	ply:ConCommand("pp_motionblur 0;pp_dof 0")
	self:Remove()
end

function ENT:OnRemove()
	timer.Destroy(tostring(self.Entity))
end